import toml


class Settings:
    def __init__(self, config_path="config.toml"):
        config = toml.load(config_path)
        self.temp_dir_root = config["temp_dir_root"]
        self.smtp_server = config["smtp_server"]
        self.smtp_port = config["smtp_port"]
        self.smtp_username = config["smtp_username"]
        self.smtp_password = config["smtp_password"]
        self.from_email = config["from_email"]
        self.api_key = config["api_key"]
        self.model = config["model"]
        self.system_prompt = config["system_prompt"]
        self.user_content = config["user_content"]
        self.nginx_static_dir = config["nginx_static_dir"]
        self.nginx_url_prefix = config["nginx_url_prefix"]
        self.dify_prefix = config["dify_prefix"]
        self.neo4j_uri = config["neo4j_uri"]
        self.neo4j_user = config["neo4j_user"]
        self.neo4j_password = config["neo4j_password"]
        self.base_url = config["base_url"]
        self.llm_max_concurrent = config["llm_max_concurrent"]
        self.owner_email_template = config["owner_email_template"]
        self.converter_fail_email_template = config["converter_fail_email_template"]
        self.converter_success_email_template = config["converter_success_email_template"]
        self.approve_email_template = config["approve_email_template"]
        self.mysql_host = config["mysql_host"]
        self.mysql_port = config["mysql_port"]
        self.mysql_user = config["mysql_user"]
        self.mysql_password = config["mysql_password"]
        self.mysql_db = config["mysql_db"]
        self.jwt_secret_key = config["jwt_secret_key"]
        self.jwt_expiration_hours = config["jwt_expiration_hours"]
        self.pdf_picture_need_desc_frame_color = config.get("pdf_picture_need_desc_frame_color", None)
        # AWS Bedrock settings
        self.bedrock_model = config.get("bedrock_model", "anthropic.claude-3-5-sonnet-20240620-v1:0")
        self.bedrock_region = config.get("bedrock_region", "ap-southeast-1")
        self.bedrock_access_key_id = config.get("bedrock_access_key_id", None)
        self.bedrock_secret_access_key = config.get("bedrock_secret_access_key", None)
        # LLM provider selection
        self.llm_provider = config.get("llm_provider", "openai")  # "openai" or "bedrock"
        self.arango_host = config["arango_host"]
        self.arango_user = config["arango_user"]
        self.arango_password = config["arango_password"]

        # dify config
        self.dify_api_key = config["dify_api_key"]
        self.dify_base_url = config["dify_base_url"]
        self.dify_embedding_model = config["embedding_model"]
        self.dify_embedding_model_provider = config["embedding_model_provider"]
        self.dify_indexing_technique = config["indexing_technique"]
        self.dify_doc_form = config["doc_form"]
        self.dify_process_rule_mod = config["process_rule_mod"]
        self.dify_rerank_model = config["rerank_model"]
        self.dify_rerank_model_provider = config["rerank_model_provider"]

        #techtanium
        self.techtanium_tenant_id = config["TENANT_ID"]
        self.techtanium_client_id = config["CLIENT_ID"]
        self.techtanium_client_secret = config["CLIENT_SECRET"]
        self.techtanium_sender = config["SENDER_EMAIL"]
settings = Settings()
